home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Conversion / Convert_PICT / Source / PictConverter.h < prev    next >
Text File  |  1993-10-02  |  8KB  |  268 lines

  1. /***********************************************************************\
  2. Converter class for Convert PICT which converts graphics from PICT to eps formats.
  3. Copyright (C) 1993 David John Burrowes
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  8.  
  9. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10.  
  11. The author, David John Burrowes, can be reached at:
  12.     davidjohn@kira.net.netcom.com
  13.     David John Burrowes
  14.     1926 Ivy #10
  15.     San Mateo, CA 94403-1367
  16. \***********************************************************************/
  17.  
  18. /*
  19. ====================================================================
  20.     This is $Revision: 1.10 $ of this file
  21.     It was last modified by $Author: death $ on $Date: 93/04/04 23:29:53 $
  22. Note that this file was created while using the New Century Schoolbook Roman typeface.  You may find that some things line up strangely if you don't use that family.
  23.  
  24. History:
  25.     93.07.18    djb    Added PicCommentOperation type, and instance variable for the same.    
  26.  
  27. $Log:    PictConverter.h,v $
  28.  * Revision 1.10  93/04/04  23:29:53  death
  29.  * Sun Apr  4 23:29:53 PDT 1993
  30.  * 
  31.  * Revision 1.9  93/01/09  21:07:07  death
  32.  * Sat Jan  9 21:07:07 PST 1993
  33.  * 
  34.  * Revision 1.8  93/01/01  11:51:16  death
  35.  * Fri Jan  1 11:51:16 PST 1993
  36.  * 
  37.  * Revision 1.7  92/12/31  15:33:53  death
  38.  * Thu Dec 31 15:33:53 PST 1992
  39.  * 
  40.  * Revision 1.6  92/12/05  23:06:26  death
  41.  * Sat Dec  5 23:06:25 PST 1992
  42.  * 
  43.  ====================================================================
  44.  */
  45.  
  46.  
  47. #import "AbstractConverter.h"
  48. #import "PICTFile.h"
  49.  
  50. //
  51. //    type styles
  52. //
  53. #define boldBit 1
  54. #define italicBit 2
  55. #define underlineBit 4
  56. #define outlineBit 8
  57. #define shadowBit 0x10
  58. #define condenseBit 0x20
  59. #define extendBit 0x40
  60.  
  61. //
  62. //    PICT modes
  63. //
  64. #define macSrcCopy 0
  65. #define macSrcOr 1
  66. #define macSrcXor 2
  67. #define macSrcBic 3
  68. #define macNotSrcCopy 4
  69. #define macNotSrcOr 5
  70. #define macNotSrcXor 6
  71. #define macNotSrcBic 7
  72. #define macPatCopy 8
  73. #define macPatOr 9
  74. #define macPatXor 10
  75. #define macPatBic 11
  76. #define macNotPatCopy 12
  77. #define macNotPatOr 13
  78. #define macNotPatXor 14
  79. #define macNotPatBic 15
  80. // Arithmetic modes defined in Inide Mac V.  
  81. #define blend 32
  82. #define addPin 33
  83. #define addOver 34
  84. #define subPin 35
  85. #define addMax 37
  86. #define subOver 38
  87. #define adMin 39
  88. // a transparent mode
  89. #define transparent 36
  90. //
  91. //    93.07.18    djb    added.
  92. //    A mysterious pen mode defined in a tech note.
  93. //    It's effect is, it seems, to be to cause QuickDraw to process stuff, but not 
  94. //    actually draw anything.
  95. //
  96. #define    magicMode    23
  97.  
  98. //
  99. //    Old style colors  (what space are those numbers in?
  100. //
  101. #define    oldBlackColor    0x0021
  102. #define    oldWhiteColor    0x001E
  103. #define    oldRedColor        0x00D1
  104. #define    oldGreenColor    0x0149
  105. #define    oldBlueColor        0x0185
  106. #define    oldCyanColor        0x010D
  107. #define    oldMagentaColor    0x0095
  108. #define    oldYellowColor    0x0059
  109.  
  110.  
  111. //
  112. //    Pixmap stuff
  113. //
  114. struct PixMap {
  115.     PICTRect bounds;            /*encloses bitmap*/
  116.     INTEGER pmVersion;            /*pixMap version number*/
  117.     INTEGER packType;             /*defines packing format*/
  118.     LONGINT packSize;            /*length of pixel data*/
  119.     FIXED hRes;             /*horiz. resolution (ppi)*/
  120.     FIXED vRes;             /*vert. resolution (ppi)*/
  121.     INTEGER pixelType;            /*defines pixel type*/
  122.     INTEGER pixelSize;            /*# bits in pixel*/
  123.     INTEGER cmpCount;             /*# components in pixel*/
  124.     INTEGER cmpSize;                /*# bits per component*/
  125.     LONGINT planeBytes;            /*offset to next plane*/
  126.     LONGINT pmTable;             /*color map for this pixMap*/
  127.     LONGINT pmReserved;            /*for future use. MUST BE 0*/
  128. };
  129.  
  130. typedef struct PixMap modPixMap;
  131.  
  132.  
  133. typedef enum piccommentoptype
  134. {
  135.     ConvertPicComments,
  136.     DiscardPicComments
  137. }
  138. PicCommentOpType;
  139.  
  140.  
  141. @interface PictConverter:AbstractConverter
  142. {
  143.     Instance    sourceFile,
  144.             destFile;
  145.     Instance    textConverter;
  146.     Boolean    UsedPatterns,
  147.             UsedColors,
  148.             UsedLines,
  149.             UsedText,
  150.             UsedRectangles,
  151.             UsedRoundRectangles,
  152.             UsedOvals,
  153.             UsedArcs,
  154.             UsedPolygons,
  155.             UsedRegions,
  156.             UsedBitmaps,
  157.             UsedComments,
  158.             UsedMiscellaneous;
  159.     CString    CodeDir;
  160.     Boolean    PackingSetting;
  161.     Boolean    UsersCharConvertChoice;
  162.     Boolean    ConvertCurrentCharacters;
  163.     PicCommentOpType    PicCommentOperation;
  164. }
  165.  
  166. //
  167. //    Administrative/ setup
  168. //
  169. - init;
  170. - free;
  171. - SetImagePacking: (Boolean) packimages UsingPSIn: (CString) newCodeDirectory;
  172. - SetConvertAllChars: (Boolean) convertAll;
  173. - SetPicCommentConversion: (PicCommentOpType) picConversion;
  174. - (Boolean) isThisAGoodFile: theFile;
  175. - (CString) SimpleStringConvert: (CString) theString;
  176. - BuildHeaderInto: thisFile;
  177. - AppendFile: (CString) codeFile To: thisFile;
  178. - BuildPrologInto: thisFile;
  179. - ConvertPICTfile: pictfile ToEPSfile: epsfile;
  180. //
  181. //    High level opcode parsers
  182. //
  183. - (Boolean) ParseOpcode: (PICTOpcode) opCode;
  184. //
  185. //    Opcode processing.
  186. //
  187. - (Boolean) ParseMiscOpcode: (PICTOpcode) opcode;
  188. - (Boolean) ParseLineOpcode: (PICTOpcode) opcode;
  189. - (Boolean) ParseTextOpcode: (PICTOpcode) opcode;
  190. - (Boolean) ParseRectangleOpcode: (PICTOpcode) opcode;
  191. - (Boolean) ParseRoundRectangleOpcode: (PICTOpcode) opcode;
  192. - (Boolean) ParseOvalOpcode: (PICTOpcode) opcode;
  193. - (Boolean) ParseArcOpcode: (PICTOpcode) opcode;
  194. - (Boolean) ParsePolygonOpcode: (PICTOpcode) opcode;
  195. - (Boolean) ParseRegionOpcode: (PICTOpcode) opcode;
  196. - (Boolean) ParseBitmapOpcode: (PICTOpcode) opcode;
  197. - (Boolean) ParseCommentOpcode: (PICTOpcode) opcode;
  198. - ParseShortComment: (Integer) kind;
  199. //
  200. //    Processing utilities
  201. //
  202. - Skip2PlusData;
  203. - Skip4PlusData;
  204. - SkipSizedObject;
  205. - ConvertHexBytes: (PositiveInteger) theBytes;
  206. - WritePoint: (PICTPoint*) thePoint;
  207. - WriteRect: (PICTRect*) theRect;
  208. - WritePSProcedureName: (CString) theName;
  209. //
  210. //    Primary data conversion routines
  211. //
  212. - ConvertArc;
  213. - ConvertAngles;
  214. - ConvertPolygon;
  215. - ConvertRegion;
  216. - ConvertMode;
  217. - ConvertFamily;
  218. - ConvertFace;
  219. - WriteString: (CString) theString;
  220. - ConvertOldColor;
  221. - ConvertRGBColor;
  222. //
  223. //    Bitmap and pattern processing
  224. //
  225. - ConvertInvertedHexBytes: (PositiveInteger) theBytes;
  226. - ConvertPict1Pattern;
  227. - ConvertPict2Pattern;
  228. - GetPixMapFrom: SourceFile  Into: (modPixMap*) nativeMap;
  229. - ConvertBitmapWithRegion: (Boolean) hasRegion PackedData: (Boolean) isPacked;
  230. - ConvertDirectBitmapWithRegion: (Boolean) hasRegion;  // new with 1.2
  231. - ConvertPackType1WithHeight: (Integer) dataHigh
  232.                 AndWidth: (Integer) rowBytes
  233.                 AndOffiset: (Integer) bitmapOffset; // New with 1.2
  234. - ConvertPackType2WithHeight: (Integer) dataHigh
  235.                 AndWidth: (Integer) rowBytes
  236.                 AndOffiset: (Integer) bitmapOffset; // New with 1.2
  237. - ConvertPackType4WithHeight: (Integer) dataHigh
  238.                 AndWidth: (Integer) rowBytes
  239.                 AndOffiset: (Integer) bitmapOffset;  // New with 1.2
  240. - ExtractImageDataUsingDataWidth: (PositiveInteger) rawWidth
  241.     Scanlines: (Integer) numLines
  242.     ScanlineLength: (Integer) bytesPerScanline
  243.     ScanlineStart: (Integer) bitOffset
  244.     AndPixelDepth: (Integer) numBits
  245.     IsCompressed: (Boolean)  sourcePacked
  246.     UsesColor: (Boolean) ColorUsed;
  247. - ConvertColorTable;
  248. - Unpack: (PositiveInteger) numBytes
  249.     BytesFrom:  (ByteString) sourceLine
  250.     Into:  (ByteString) destLine;
  251. -(PositiveInteger) Pack: (PositiveInteger) numBytes
  252.     BytesFrom:  (ByteString) source
  253.     Into:  (ByteString) dest;
  254. - Invert: (Integer) numBytes In: (ByteString) theBuffer;
  255. - (ByteString) Copy: (PositiveInteger) sourceSize
  256.     BitsAtOffset: (PositiveInteger) offset
  257.     From: (ByteString) source
  258.     Into: (ByteString) dest;
  259.  
  260. @end
  261.  
  262. #define    ERR_APPENDFAILED    -30
  263. #define    ERR_BADSOURCESIZE    201
  264. #define    ERR_UNKNOWNPACK    -1000
  265. #define    ERR_BADPACK            1001
  266. #define    ERR_NOSIXTEEN        -1002
  267.  
  268.